package com.aiyige.page.detail.adpater;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.aiyige.MyApp;
import com.aiyige.R;
import com.aiyige.model.Subject;
import com.aiyige.model.moment.entity.Moment;
import com.aiyige.utils.ListUtil;
import com.aiyige.utils.StringUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

/**
 * Created by zhuyakun on 2017/10/26.
 */

public class DetailAboutAdapter extends BaseMultiItemQuickAdapter<Moment, BaseViewHolder> {

    public DetailAboutAdapter() {
        super(new LinkedList<Moment>());
        addItemType(0, R.layout.item_detail_video);
    }

    @Override
    protected void convert(BaseViewHolder helper, Moment item) {
        if (!ListUtil.isEmpty(item.getCover())) {
            Glide.with(mContext).load(item.getCover().get(0)).into((ImageView) helper.getView(R.id.iv_video_cover));
        }
        helper.setText(R.id.tv_video_title,item.getTitle());
        String subject = item.getSubject();
//        helper.setVisible(R.id.iv_video_watch_count, !TextUtils.isEmpty(item.getSubject()) && (item.getSubject().equals(Subject.video) || item.getSubject().equals(Subject.video_course)));
//        helper.setText(R.id.tv_video_watch_count, StringUtils.getBuyInfoText(subject,item.getStatisticsBackup()));
        helper.setVisible(R.id.iv_play, !TextUtils.isEmpty(item.getSubject()) && (item.getSubject().equals(Subject.video) || item.getSubject().equals(Subject.video_course)));
        long count = item.getStatisticsBackup() != null ? item.getStatisticsBackup().getViewCount() : 0;
        if (subject.equals(Subject.video_course) || subject.equals(Subject.major_course) || subject.equals(Subject.training_course)
                || subject.equals(Subject.training_card)) {
            helper.setVisible(R.id.iv_video_watch_count,false);
            helper.setText(R.id.tv_video_watch_count, MyApp.getAppContext().getString(R.string.sell_count_value, (item.getStatisticsBackup() != null ? item.getStatisticsBackup().getSellCount() : 0) + ""));
        } else if (subject.equals(Subject.video)) {
            helper.setImageResource(R.id.iv_video_watch_count, R.drawable.detail_video_browse);
            helper.setText(R.id.tv_video_watch_count, "" + count);
        } else {
            helper.setImageResource(R.id.iv_video_watch_count,R.drawable.detail_browse);
            helper.setText(R.id.tv_video_watch_count, "" + count);
        }


        // 电视图标 视频   其他的都是眼睛  商品已购

    }


}
